package de.geckocraft.GeckoEventBroadcaster.Main;

import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;

import de.geckocraft.GeckoEventBroadcaster.Commands.*;


public final class Main extends JavaPlugin
{
	public static Plugin plugin;
	public static Main main;
	
	public void onEnable()
	{
		plugin = this.getServer().getPluginManager().getPlugin(this.getName());
		loadConfigs();
		commands();
		AutoBroadcast.autocast();
	}

	public void onDisable()
	{
		
	}

	public static void loadConfigs()
	{
		Template.loadConfig();
		MainConfig.loadConfig();
		EventList.loadConfig();
	}
	
	private void commands()
	{
		getCommand("event").setExecutor(new Events(this));
	}
	
	public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args)
	{
		return false;
	}
	
	public static Plugin getPlugin()
	{
		Plugin p = plugin;
		return p;
	}
	
	public static Main getMain()
	{
		Main main = (Main) plugin;
		return main;
	}
	
	// Zusatzcode
	public static boolean isInteger(String string)
	{
		boolean returnWert = false;
		try
		{
			Integer.parseInt(string);
			returnWert = true;
		} catch (Exception e)
		{
			returnWert = false;
		}
		return returnWert;
	}
}
